Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): add amount args for ERC20 withdraw tests #3113

Merged
merged 5 commits into from
Nov 8, 2024

Conversation

lumtis
Copy link
Member

@lumtis lumtis commented Nov 6, 2024

Description

Add args

  • TestV2ERC20WithdrawAndCallNoMessageName actually expected an arg and it was missing (the test was also not run)
  • Add for TestV2ERC20WithdrawAndCall, despite the previous note, better to add an arg for consistency with other test, it doesn't add overhead as you have a default value and in the future we could whitelist a ERC20 with a high base price (unlikely)

Summary by CodeRabbit

  • New Features

    • Introduced a new end-to-end test case for the ERC20 token withdrawal workflow.
    • Enhanced argument definitions for existing ERC20 withdrawal tests to include an "amount" parameter with a default value of 1000.
  • Bug Fixes

    • Improved validation for the withdrawal amount in the ERC20 withdrawal test, ensuring proper error handling for invalid inputs.

@lumtis lumtis added the no-changelog Skip changelog CI check label Nov 6, 2024
Copy link
Contributor

coderabbitai bot commented Nov 6, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request introduces enhancements to the end-to-end testing framework for ERC20 token workflows. A new test case, e2etests.TestV2ERC20WithdrawAndCallNoMessageName, is added to the existing startV2Tests function, which continues to manage both successful and error scenarios. Additionally, modifications are made to the argument definitions for two existing tests, requiring an "amount" parameter with a default value of 1000. The TestV2ERC20WithdrawAndCall function is updated to dynamically retrieve this amount, replacing a hardcoded value.

Changes

File Path Change Summary
cmd/zetae2e/local/v2.go Added new test case e2etests.TestV2ERC20WithdrawAndCallNoMessageName to startV2Tests.
e2e/e2etests/e2etests.go Updated argument definitions for TestV2ERC20WithdrawAndCall and TestV2ERC20WithdrawAndCallNoMessage to include Description: "amount", DefaultValue: "1000".
e2e/e2etests/test_v2_erc20_withdraw_and_call.go Modified TestV2ERC20WithdrawAndCall to accept args []string, replacing hardcoded amount with dynamic retrieval from args[0].

Possibly related PRs

Suggested labels

V2_TESTS

Suggested reviewers

  • skosito
  • kingpinXD
  • ws4charlie
  • brewmaster012
  • fbac
  • swift1337

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lumtis lumtis marked this pull request as ready for review November 6, 2024 13:30
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (4)
e2e/e2etests/test_v2_erc20_withdraw_and_call.go (2)

15-17: Enhance args validation with descriptive error message.

While the length validation is correct, consider improving the error message to be more descriptive about the expected format.

-func TestV2ERC20WithdrawAndCall(r *runner.E2ERunner, args []string) {
-	require.Len(r, args, 1)
+// TestV2ERC20WithdrawAndCall tests ERC20 withdrawal with a custom payload
+// args[0]: amount - the withdrawal amount in base units (e.g., "1000")
+func TestV2ERC20WithdrawAndCall(r *runner.E2ERunner, args []string) {
+	require.Len(r, args, 1, "TestV2ERC20WithdrawAndCall requires exactly one argument: amount")

19-23: Extract gas limit constant and consider helper function.

The gas limit management is correct but could be improved for maintainability and reusability.

+const (
+    // DefaultWithdrawGasLimit is the gas limit used for withdrawal operations
+    DefaultWithdrawGasLimit = 10000000
+)
+
+// withCustomGasLimit temporarily sets a custom gas limit and restores the original value
+func withCustomGasLimit(r *runner.E2ERunner, gasLimit uint64) func() {
+    previousGasLimit := r.ZEVMAuth.GasLimit
+    r.ZEVMAuth.GasLimit = gasLimit
+    return func() { r.ZEVMAuth.GasLimit = previousGasLimit }
+}

 func TestV2ERC20WithdrawAndCall(r *runner.E2ERunner, args []string) {
     // ...
-    previousGasLimit := r.ZEVMAuth.GasLimit
-    r.ZEVMAuth.GasLimit = 10000000
-    defer func() {
-        r.ZEVMAuth.GasLimit = previousGasLimit
-    }()
+    defer withCustomGasLimit(r, DefaultWithdrawGasLimit)()
cmd/zetae2e/local/v2.go (2)

Line range hint 89-91: Consider tracking the TODO as a GitHub issue.

The TODO comment indicates future work to break down this routine. While the current implementation works, tracking this technical debt would help with future maintenance.

Would you like me to create a GitHub issue to track this refactoring task?


Line range hint 15-84: Well-structured test organization with room for enhancement.

The current implementation demonstrates good practices:

  • Parallel test execution using errgroup
  • Clear separation of concerns between gas token and ERC20 workflows
  • Visual differentiation using color coding

Consider enhancing the structure by:

  1. Adding package-level documentation about the test organization strategy
  2. Considering table-driven tests for similar test cases
  3. Adding metrics collection for test execution times
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9cf3635 and c0400e7.

📒 Files selected for processing (3)
  • cmd/zetae2e/local/v2.go (1 hunks)
  • e2e/e2etests/e2etests.go (1 hunks)
  • e2e/e2etests/test_v2_erc20_withdraw_and_call.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
cmd/zetae2e/local/v2.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

e2e/e2etests/e2etests.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

e2e/e2etests/test_v2_erc20_withdraw_and_call.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

🔇 Additional comments (2)
cmd/zetae2e/local/v2.go (1)

42-42: LGTM: Test case addition is well-placed.

The new test case is appropriately placed within the ERC20 happy path test group, maintaining a logical organization of test cases.

e2e/e2etests/e2etests.go (1)

958-960: LGTM: Argument definition follows consistent pattern.

The addition of the amount argument with a default value of "1000" aligns with other ERC20 withdraw tests and improves consistency.

e2e/e2etests/e2etests.go Show resolved Hide resolved
@lumtis lumtis added this pull request to the merge queue Nov 7, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 7, 2024
@lumtis lumtis added the UPGRADE_LIGHT_TESTS Run make start-upgrade-test-light label Nov 8, 2024
@lumtis lumtis added the V2_TESTS Run make start-v2-test label Nov 8, 2024
Copy link

codecov bot commented Nov 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.29%. Comparing base (0e86494) to head (43be443).
Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3113   +/-   ##
========================================
  Coverage    63.29%   63.29%           
========================================
  Files          422      422           
  Lines        29959    29959           
========================================
  Hits         18962    18962           
  Misses       10157    10157           
  Partials       840      840           

see 1 file with indirect coverage changes

@lumtis lumtis added this pull request to the merge queue Nov 8, 2024
Merged via the queue into develop with commit 6d7b91d Nov 8, 2024
41 checks passed
@lumtis lumtis deleted the e2e/set-args-erc20-withdraws branch November 8, 2024 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking:cli no-changelog Skip changelog CI check UPGRADE_LIGHT_TESTS Run make start-upgrade-test-light V2_TESTS Run make start-v2-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants